package com.imast.android.bys.receiver;

import static com.imast.android.bys.util.LogUtils.*;

import com.imast.android.bys.service.GCMIntentService;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;

public class GCMBroadcastReceiver extends WakefulBroadcastReceiver {

	private static final String TAG = GCMBroadcastReceiver.class.getSimpleName();
	
	@Override
	public void onReceive(Context context, Intent intent) {
		
		if (intent.getAction() != null) {
			
			LOGD(TAG, intent.getAction());
			
			if (intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION") || intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
				ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
				startWakefulService(context, (intent.setComponent(comp)));	
			} 
			
		}
			
	}

}
